<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="websql.*"%>
<%@page import="unit.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>


<script type="text/javascript">
var xmlHttp;
var requestType = "";
//创建XMLHttpRequest对象
function GetXmlHttpObject() {
	var xmlHttp;
	 try
	    {
	   // Firefox, Opera 8.0+, Safari
	    xmlHttp=new XMLHttpRequest();
	    }
	 catch (e)
	    {
	  // Internet Explorer
	   try
	      {
	      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	      }
	   catch (e)
	      {
	      try
	         {
	         xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	         }
	      catch (e)
	         {
	         alert("您的浏览器不支持AJAX！");
	         return false;
	         }
	      }
	    }
	    return xmlHttp;
	}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("qtab").innerHTML=xmlHttp.responseText;
 } 
}



function showcid()
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
	 alert ("您的浏览器不支持AJAX！");
	 return
	 }
	var url="getquerytab.jsp";
	url=url+"?cid="+document.getElementById("cid").value;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged ;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
}

function stateChangedq() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("query").innerHTML=xmlHttp.responseText;
 } 
}



function showqid()
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
	 alert ("您的浏览器不支持AJAX！");
	 return
	 }
	
	var url="getqueryinfo.jsp";
	url=url+"?qid="+document.getElementById("qid").value;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChangedq ;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
}

</script>


</head>
<body>

<%
	request.setCharacterEncoding("UTF-8");
%>
<form action="setquery_action.jsp" method="post"><select name='cid'
	id="cid" onchange="showcid()">
	<option value="">请选择数据库连接</option>
	<%
		String cname[] = websql.Conn.getConnNames();
		for (int i = 0; i < cname.length; i++) {
			out.print("<option value =\""
					+ Conn.getcid("cname", EscapeUnescape.escape(cname[i]))
					+ "\">" + cname[i] + "</option>");
		}
	%>
</select>
<div id='qtab'></div>

</form>
</body>
</html>